#include "stdafx.h"
#include "UserMgr.h"

TAUTH UserMgr::QueryProxyUser(int pid)
{
    std::unique_lock<std::mutex> lock{this->m_Proxylock};
    auto iter = m_ProxyList.find(pid);
    if (iter != m_ProxyList.end())
    {
        return iter->second;
    }
    return 0;
}
void UserMgr::DellProxyUser(int pid)
{
    std::unique_lock<std::mutex> lock{this->m_Proxylock};
    auto iter = m_ProxyList.find(pid);
    if (iter != m_ProxyList.end())
    {
        m_ProxyList.erase(iter);
    }
}

void UserMgr::AddProxyUser(int pid, TAUTH au)
{
    std::unique_lock<std::mutex> lock{this->m_Proxylock};
    auto iter = m_ProxyList.find(pid);
    if (iter != m_ProxyList.end())
    {
        m_ProxyList.erase(iter);
    }
    m_ProxyList[pid] = au;
}
UserMgr::UserMgr()
{
}

UserMgr::~UserMgr()
{
    std::unique_lock<std::mutex> lock{this->m_Proxylock};
    m_ProxyList.clear();
}